﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;

namespace ArgusLib.Fractals.OrbitFractals
{
	public abstract class MandelbrotSetBase : Fractal
	{
		public MandelbrotSetBase(Parameter parameter)
			: base(parameter)
		{
		}

		protected override void IteratePoint(int x, int y)
		{
			if (this.DataSet.IsNull(x, y) == false)
				return;
			Complex c = this.DataSet.Convert(x, y);
			this.DataSet[x, y] = c;
			while(this.DataSet[x,y].Magnitude < 2)
			{
				this.DataSet[x, y] = this.IterationFormula(this.DataSet[x, y], c);
				if (this.DataSet.Iterations[x, y] >= this.Parameter.Iterations)
					break;
			}
		}

		protected abstract Complex IterationFormula(Complex z, Complex c);
	}
}
